import { Entity, PrimaryGeneratedColumn, Column, Index } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

/**
 * 挖宝历史日志（用于 1592 动态、风控、审计）
 * 仅记录已结算的挖掘事件
 */
@Entity("tomb_dig_log")
@ManualTimestamp()
@Index(["characterId", "created_at"]) // 最近记录查询
export class TombDigLogEntity {
  @PrimaryGeneratedColumn({ type: "int", comment: "日志ID" })
  id!: number;

  @Column({ type: "int", name: "character_id", comment: "角色ID" })
  characterId!: number;

  @Column({ type: "int", name: "pit_id", comment: "坑位ID（tomb_pit.id）" })
  pitId!: number;

  @Column({ type: "int", name: "page_index", comment: "页索引" })
  pageIndex!: number;

  @Column({ type: "int", name: "pit_index", comment: "坑位索引 0..8" })
  pitIndex!: number;

  @Column({ type: "int", name: "result_type", comment: "2中奖，3挖空" })
  resultType!: number;

  @Column({
    type: "int",
    name: "reward_type",
    comment: "奖励中类类型码 1..8，9空",
  })
  rewardType!: number;

  @Column({
    type: "varchar",
    length: 200,
    name: "reward_desc",
    comment: "奖励描述文案",
  })
  rewardDesc!: string;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date | null;
}
